<template>
  <div class="app-container">
    <el-tabs v-model="activeName" type="card" @tab-remove="removeTab" @tab-click="tabClick">
      <el-tab-pane label="任务列表" name="1">
        <template v-if="activeName === '1'">
          <BaseValue></BaseValue>
        </template>
      </el-tab-pane>
      <el-tab-pane label="我的任务" name="2">
        <template v-if="activeName === '2'">
          <Related ref="iscond">
          </Related>
        </template>
      </el-tab-pane>
      <template v-if="tabIndex">
        <el-tab-pane label="任务详情" name="3" closable>
          <template v-if="activeName === '3'">
            <Detailed :rowObj="rowObj"></Detailed>
          </template>
        </el-tab-pane>
      </template>
    </el-tabs>
  </div>
</template>

<script>
export default {
  name: "Task",
  // dicts: ['sys_notice_status', 'sys_notice_type'],
  components: {
    BaseValue: () => import('./frontPage/index.vue'),//列表
    Related: () => import('./related/index.vue'),//我的
    Detailed: () => import('./frontPage/form/detailed.vue'),//详情
    // operationTable: ()=> import('./operation-table/index.vue')
  },
  data () {
    return {
      activeName: '1',
      tabIndex: false,
      rowObj: {}
    };
  },
  computed: {
    isCondition: {
      get () {
        return this.$store.state.user.isCondition
      }
    },

  },
  created () {
    // this.activeName = this.isCondition
    // console.log(this.isCondition, this.$route.query.isCondition);
    if (this.isCondition === '2') {
      this.activeName = '2'
      setTimeout(() => {
        this.$refs['iscond'].handleQuery({ 'params[upkeepStatus]': '1' });
      }, 500);
    }
    if (this.isCondition === '3') {
      this.activeName = '2'
      setTimeout(() => {
        this.$refs['iscond'].handleQuery({ 'params[acceptanceStatus]': '0' });
      }, 500);
    }
  },
  mounted () {
    if (this.$route.query.sourceId) {//存在详情id则进入直接进入详情界面
      this.activeName = '3'
      this.tabIndex = true
      this.rowObj = {
        upkeepTaskId: this.$route.query.sourceId,
        equipmentAccountId: 0
      }
    }
  },
  methods: {
    tabClick () {
      if (this.activeName === '1' || this.activeName === '2') {
        this.tabIndex = false
      }

    },
    removeTab () {
      this.tabIndex = false
      this.activeName = '2'
    },
    // addTab(row){
    //   this.tabIndex = true
    //   this.activeName = '3'
    //   this.rowObj = row
    // }
  }
};
</script>
